<?php
//upload file controller
define('IN_T', true);

require 'source/include/init.php';


$prefix = $_POST['prefix'];
$fileName = $_POST['key'];
$fileId = $_POST['file_id'];

$realFileName = $_FILES['file']['name'];
$file = $_FILES['file']['tmp_name'];
//var_dump(ROOT_PATH.'/temp/'.$fileName);
//die;
$path     = dirname(ROOT_PATH . '/temp/' . $fileName);
!is_dir($path) && mkdir($path, 0755, true);
//todo 递归创建目录
file_put_contents(ROOT_PATH . '/temp/' . $fileName, file_get_contents($file));

$res = [
    'imgsrc' => $fileName,
    'imgname' => $realFileName,
];
echo json_encode($res);

?>